<?php

namespace App\Jobs;

use Illuminate\Bus\Batchable;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;

class ProcessAddLocation implements ShouldQueue
{
    use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    private $data;
    public function __construct($data)
    {
        $this->data = $data;
//        dump("processAdd");
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $redis= new Redis();
        Log::info('ProcessAddLocation: {android_id},{lotitude},{latitude}', ['android_id' => $this->data['android_id'],"lotitude"=>$this->data['lotitude'],"latitude"=>$this->data['latitude']]);
//        $redis::zrem("position_list",$this->data['android_id']);
        $ret = $redis::geoadd("position_list",$this->data['lotitude'],$this->data['latitude'],$this->data['android_id']);
        Log::info('ProcessAddLocation: {ret}', ['ret'=>$ret]);
    }
}
